package com.crm.controller.saling;

import com.crm.service.saling.CODetailsService;
import com.crm.service.saling.ContractService;
import com.crm.vo.ContractClientCodetailsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by dr5hx on 2018/8/30
 */
@Controller
public class CoDetailsController {
    @Autowired
    private CODetailsService coDetailsService;
    @Autowired
    private ContractService contractService;

    /**
     * 查询所有的订单详细数据
     *
     * @return
     */
    @PostMapping("getContractClientCodetailsVOList")
    @ResponseBody
    public Map getContractClientCodetailsVOList(int page, int rows) {
        try {
            List<ContractClientCodetailsVO> list = coDetailsService.getContractClientCodetailsVOList(page, rows);
            Long count = contractService.getContractExistCount();
            Map map = new HashMap();
            map.put("rows", list);
            map.put("total", count);
            return map;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    @GetMapping("toContractClientCodetailsVOList")
    public String toContractClientCodetailsVOList() {
        return "saling/codetailsList";
    }

}
